package com.nbb.demo.shardingjdbc.controller;

import com.nbb.demo.shardingjdbc.entity.User;
import com.nbb.demo.shardingjdbc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: Jerry
 * @time: 2021/3/26 15:41
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public String add(@RequestBody User user) {
        user.insert();
        return "ok";
    }

    @PostMapping("/list")
    public String list() {
        return userService.list().toString();
    }
}
